#ifndef LINK_H_
#define LINK_H_

typedef struct link_t {
	int addr;
	int sockfd;
	int port;
} link_t;

enum {
	LINK_DISCONNECTED = -2,
	LINK_ERROR = -1,
	LINK_SUCCESS = 0
};

typedef void (*on_accept) (link_t* remote, void* port, int* abort);

int link_init();

int link_connect(link_t* l);

int link_listen(link_t* l, int max_connections);

int link_accept(link_t* l, on_accept fp_accept, void* arg);

int link_send_raw(link_t* l, char* buffer, int size);

int link_receive_raw(link_t* l, char* buffer, int size, int* received);

int link_close(link_t* l);

#endif  /* LINK_H_ */
